package com.jr.controller;

import com.jr.entry.Airports;
import com.jr.entry.FlightTickets;
import com.jr.entry.Flights;
import com.jr.mapper.FlightMapper;
import com.jr.mapper.FlightTicketsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController
@RequestMapping("/fly/")
public class FlightController {
    @Autowired
    private FlightMapper flightMapper;
    @Autowired
    private FlightTicketsMapper flightTicketsMapper;
    @RequestMapping("find")
    public ArrayList<Flights> findAll(Flights flights){
        ArrayList<Flights> list = flightMapper.selectFly(flights);
        return list;
    }
    @RequestMapping("findId")
    public Airports  findId(Airports airports){
        ArrayList<Airports> airports1 = flightMapper.selectAir(airports);
        for (Airports a :
                airports1) {
              airports.setAirport_name(a.getAirport_name());
              airports.setId(a.getId());
        }
        return airports;
    }
    @RequestMapping("tick")
    public ArrayList<FlightTickets> findtic(FlightTickets flightTickets){
        ArrayList<FlightTickets> flightTickets1 = flightTicketsMapper.selectTick(flightTickets);
        return flightTickets1;
    }
}
